<?php
/**
 * Created by PhpStorm.
 * User: weijer
 * Date: 2018/10/26
 * Time: 21:17
 */

namespace common\validate;

use think\Validate;

class Supplier extends BaseValidate
{
    //验证规则
    protected $rule = [];

    // Fields 验证场景定义
    public function sceneFields()
    {
        return $this;
    }

    // Find 验证场景定义
    public function sceneFind()
    {
        return $this->append('param', 'require')
            ->append('param.filter', 'array');
    }

    // Create 验证场景定义
    public function sceneCreate()
    {
        return $this->append('data.user_id', 'integer')
            ->append('data.type', 'require|in:inside,outside')
            ->append('data.tenant_id', 'require')
            ->append('data.from_tenant_id', 'require')
            ->append('data.step_category_ids', 'max:255');
    }

    // Update 验证场景定义
    public function sceneUpdate()
    {
        return $this->append('data.id', 'require')
            ->append('data.type', 'in:inside,outside')
            ->append('data.step_category_ids', 'max:255');
    }

    // Delete 验证场景定义
    public function sceneDelete()
    {
        return $this->append('param.filter', 'require');
    }

    // Select 验证场景定义
    public function sceneSelect()
    {
        return $this->append('param', 'array')
            ->append('param.filter', 'array')
            ->append('param.page', 'array');
    }

    // GetSupplierByPhone 验证场景定义
    public function sceneGetSupplierByPhone()
    {
        return $this->append('param.filter.phone', 'require');
    }

    // BaseFind 验证场景定义
    public function sceneBaseFind()
    {
        return $this
            ->append('param.filter', 'require');
    }


    public function sceneGetSupplierCustomerList()
    {
        return $this->append('param', 'array')
            ->append('param.filter', 'array')
            ->append('param.page', 'array');
    }

    // GetSupplierByName 验证场景定义
    public function sceneGetSupplierByName()
    {
        return $this->append('param.filter.name', 'require');
    }

}
